<?php

class  Somi_Models_Firma extends Zend_Db_Table_Abstract 
{
	protected $_name='firma';
	protected $_primary = 'firma_id';
	#protected $_rowClass = 'user';
	protected $_sequence  = true;
	
	#protected $_dependentTables = array('email');
	protected $_referenceMap = array(
		'Auftrag' => array(
		'colums' => 'firma_id',
		'refTableClass' => 'auftrag',
		'refColums'		=> 'firma_id',
	));
	
	
    public function getFirma($id){		
    	$firma=$this->fetchRow('firma_id="'.$id.'"');
    	return $firma;
    }
    
    public function getAll(){
    	
    	$db= Zend_Registry::get('db');
    	$select=$db->select();
    	$select->from('firma');
    	$erg=$db->fetchAll($select);
    	return $erg;
    }
    
    public function update($daten,$id){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->update('firma',$daten,'firma_id="'.$id.'"');
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}    	
    }
    
	public function insert($daten){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->insert('firma',$daten);
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}   	
    }
    
	public function delete($id){
    	$db= Zend_Registry::get('db');
    	$db->beginTransaction();
    	try{
    	$db->delete('firma','firma_id="'.$id.'"');
    	$db->commit();
    	}catch(Exception $e){
    		$db->rollBack();
    	}   	
    }
    
    
	public function getRole(){
    	$db= Zend_Registry::get('db');
		$temp = $db->describeTable('firma'); 
		$temp_enum=$temp['role']['DATA_TYPE'];
		$temp=explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$temp_enum));		
    	return $temp;
    	
    }
    
	
}

?>